package com.hqyj.system.service.impl;


import com.hqyj.system.mapper.UserMapper;
import com.hqyj.system.model.User;
import com.hqyj.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName UserServiceImpl
 * @Description
 * @Author zlf
 * @Date 2021/8/28 10:05
 * @Version 1.0
 **/
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User queryUserByUsernameAndPassword(User user) {
        User user_db = userMapper.queryUserByUsernameAndPassword(user);
        System.out.println(user_db);
        return user_db;
    }

    @Override
    public List<User> queryAllUser() {
        List<User> user_dbList = userMapper.queryAllUser();
        return user_dbList;
    }

    @Override
    public int addUserByUser(User user) {
        userMapper.insertSelective(user);
        return 1;
    }

    @Override
    public int deleteUserById(int userId) {
        int n = userMapper.deleteByPrimaryKey(userId);
        return n;
    }

    @Override
    public User queryUserById(int userId) {
        User user_db = userMapper.selectByPrimaryKey(userId);
        return user_db;
    }

    @Override
    public int updateUserByUser(User user) {
        int n = userMapper.updateByPrimaryKeySelective(user);
        return n;
    }

    @Override
    public User queryUserByUsername(String username) {
        return userMapper.queryUserByUsername(username);
    }
}
